//
//  ProductBuyNumCell.m
//  MJApp
//
//  Created by John on 15/3/30.
//  Copyright (c) 2015年 wangliang. All rights reserved.
//

#import "ProductBuyNumCell.h"
@interface ProductBuyNumCell()
@property (weak, nonatomic) IBOutlet UIView *opreateBgView;
@property (weak, nonatomic) IBOutlet UILabel *numLabel;

@end
@implementation ProductBuyNumCell

- (void)awakeFromNib {
    // Initialization code
    
    self.currNum = 1;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
+(instancetype)cellForTableview:(UITableView *)tableview{

    static NSString * ID = @"ProductBuyNumCell";
    ProductBuyNumCell * cell = [tableview dequeueReusableCellWithIdentifier:ID];
    if (cell == nil) {
        cell = [[NSBundle mainBundle] loadNibNamed:ID owner:nil options:nil].lastObject;
    }
    cell.cellH = 60;
    
    return cell;
}
- (IBAction)addBtnClick:(id)sender {
    
    NSInteger num = [self.numLabel.text integerValue];
    ++num;
    self.numLabel.text = [NSString stringWithFormat:@"%ld",(long)num];
    self.currNum = num;
}
- (IBAction)subBtnClick:(id)sender {
    NSInteger num = [self.numLabel.text integerValue];
    if (num>1) {
        --num;
    }
    self.numLabel.text = [NSString stringWithFormat:@"%ld",(long)num];
    self.currNum = num;
}

- (void)setCurrNum:(NSInteger)currNum {
    
    _currNum = currNum;
    self.numLabel.text = [NSString stringWithFormat:@"%ld",currNum];
}

//- (NSInteger)currNum {
//    
//    NSString *numStr = self.numLabel.text;
//    return [numStr integerValue];
//}

@end
